#include<bits/stdc++.h>
#define N 100005
using namespace std;
struct Node{
    int f,v0,a;
}car[100005];
int t,n,m,l,v,i,j,o;
bool A=1,B=1,C=1;
bool kep[100005];
int che[100005],sum;
bool vt(int V0,int a0,int S,int V){
    if(V0*V0+2*a0*S>V*V) return true;
    else return false;
}
void aa(){
    for(i=1;i<=n;i++){
        if(car[i].v0>v&&car[i].f<=che[m]){
            sum++;
        }
    }
    cout<<sum<<" ";
    if(sum==0) cout<<m<<endl;
    else cout<<m-1<<endl;
    return ;
}
void bb(){
    for(i=1;i<=n;i++){
        if(car[i].f<=che[m]){
            if(vt(car[i].v0 , car[i].a , che[m]-car[i].f , v)){
                sum++;
            }
        }
    }
    cout<<sum<<" ";
    if(sum==0) cout<<m<<endl;
    else cout<<m-1<<endl;
    return ;
}
void cc(){
    int p=0;
    memset(kep,0,sizeof(kep));
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(car[i].f<=che[j]){
                kep[j]=1;
                break;
            }
        }
        if(vt(car[i].v0 , car[i].a , che[j]-car[i].f , v)){
            sum++;
        }
    }
    cout<<sum<<" ";
    for(i=1;i<=m;i++){
        if(kep[i]==1){
            p++;
        }
    }
    if(sum==0) cout<<m<<endl;
    else cout<<p<<endl;
    return ;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(o=1;o<=t;o++){
        A=1;B=1;C=1;sum=0;
        cin>>n>>m>>l>>v;
        for(i=1;i<=n;i++){
            cin>>car[i].f>>car[i].v0>>car[i].a;
            if(car[i].a!=0) A=0;
            if(car[i].a>=0) C=0;
            if(car[i].a<=0) B=0;
        }
        for(i=1;i<=m;i++){
            cin>>che[i];
        }
        if(A) aa();
        if(B) bb();
        if(C) cc();
    }
}
